package com.stylefeng.guns.modular.hhtb.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.hhtb.model.Inviteid;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.hhtb.service.IInviteidService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-09-14 18:49:05
 */
@Controller
@RequestMapping("/inviteid")
public class InviteidController extends BaseController {

    private String PREFIX = "/hhtb/inviteid/";

    @Autowired
    private IInviteidService inviteidService;

    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "inviteid.html";
    }

    /**
     * 跳转到添加
     */
    @RequestMapping("/inviteid_add")
    public String inviteidAdd() {
        return PREFIX + "inviteid_add.html";
    }

    /**
     * 跳转到修改
     */
    @RequestMapping("/inviteid_update/{inviteidId}")
    public String inviteidUpdate(@PathVariable Integer inviteidId, Model model) {
        Inviteid inviteid = inviteidService.selectById(inviteidId);
        model.addAttribute("item",inviteid);
        LogObjectHolder.me().set(inviteid);
        return PREFIX + "inviteid_edit.html";
    }

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return inviteidService.selectList(null);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(Inviteid inviteid) {
        inviteidService.insert(inviteid);
        return SUCCESS_TIP;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer inviteidId) {
        inviteidService.deleteById(inviteidId);
        return SUCCESS_TIP;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(Inviteid inviteid) {
        inviteidService.updateById(inviteid);
        return SUCCESS_TIP;
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{inviteidId}")
    @ResponseBody
    public Object detail(@PathVariable("inviteidId") Integer inviteidId) {
        return inviteidService.selectById(inviteidId);
    }
}
